Backbone.View.extend.render   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 9.4285
1
import Backbone from 'backbone';
0 ignored issues
show
introduced by
Definition for rule 'keyword-spacing' was not found
Loading history...
2
3
import {
4
  Backgrid
5
} from './core.js';
6
import {
7
  Columns
8
} from './columns.js';
9
import {
10
  HeaderRow
11
} from './header_row.js';
12
/**
13
   Header is a special structural view class that renders a table head with a
14
   single row of header cells.
15
16
   @class Backgrid.Header
17
   @extends Backbone.View
18
 */
19
var Header = Backgrid.Header = Backbone.View.extend({
20
21
  /** @property */
22
  tagName: "thead",
23
24
  /**
25
     Initializer. Initializes this table head view to contain a single header
26
     row view.
27
28
     @param {Object} options
29
     @param {Backbone.Collection.<Backgrid.Column>|Array.<Backgrid.Column>|Array.<Object>} options.columns Column metadata.
30
     @param {Backbone.Model} options.model The model instance to render.
31
32
     @throws {TypeError} If options.columns or options.model is undefined.
33
   */
34
  initialize: function (options) {
35
    this.columns = options.columns;
36
    if (!(this.columns instanceof Backbone.Collection)) {
37
      this.columns = new Columns(this.columns);
38
    }
39
40
    this.row = new HeaderRow({
41
      columns: this.columns,
42
      collection: this.collection
43
    });
44
  },
45
46
  /**
47
     Renders this table head with a single row of header cells.
48
   */
49
  render: function () {
50
    this.$el.append(this.row.render().$el);
51
    this.delegateEvents();
52
    return this;
53
  },
54
55
  /**
56
     Clean up this header and its row.
57
58
     @chainable
59
   */
60
  remove: function () {
61
    this.row.remove.apply(this.row, arguments);
62
    return Backbone.View.prototype.remove.apply(this, arguments);
63
  }
64
65
});
66
export {
67
  Header
68
};
69